// 权限控制
import router from "./router"
import { getToken } from "./utils/auth"

const WHITE_LIST = ['/login', '/404']
router.beforeEach((to, form, next) => {
    const token = getToken()
    
    // 有token的情况
    if (token) {
        next()
    } else {
        // 没有token的情况
        if (WHITE_LIST.includes(to.path)) {
            next()
        } else {
            next('/login')
        }
    }
})